#include "MouseUtility.h"
#include "ResourceManager.h"
MouseUtility* MouseUtility::_instance = NULL;
MouseUtility::MouseUtility()
{
	m_mouseX = m_mouseY = 0;
	m_isLClicked = false;
	m_isRClicked = false;
}


MouseUtility::~MouseUtility(void)
{
}
MouseUtility* MouseUtility::GetInst()
{
	if(MouseUtility::_instance == NULL)
	{
		_instance = new MouseUtility();
	}
	return _instance;
}
void MouseUtility::updateMousePos(float _posX, float _posY)
{
	m_mouseX = _posX;
	m_mouseY = _posY;
}
float MouseUtility::getMouseX()
{
	return m_mouseX;
}
float MouseUtility::getMouseY()
{
	return m_mouseY;
}
void MouseUtility::getWinSize(int _W, int _H)
{
	m_winHeight = _H;
	m_winWidth = _W;
}
int MouseUtility::getWinHeight()
{
	return m_winHeight;
}
int MouseUtility::getWinWidth()
{
	return m_winWidth;
}
float MouseUtility::getWinRatio()
{
		return (float) m_winWidth / m_winHeight;
}
void MouseUtility::convertToWinCoor(float &_X, float &_Y)
{
	_Y = (float) -(getMouseY() - getWinHeight()/2) / (getWinHeight() + 15);
	_X = (float) ((getMouseX() - getWinWidth()/2) / (getWinWidth() + 30) ) * getWinRatio();
}
void MouseUtility::convertToWinCoor()
{
	m_mouseWinY = (float) -(getMouseY() - getWinHeight()/2) / (getWinHeight() + 15);
	m_mouseWinX = (float) ((getMouseX() - getWinWidth()/2) / (getWinWidth() + 30) ) * getWinRatio();
}
float MouseUtility::getGLMouseX()
{
	m_mouseWinX = (float) ((getMouseX() - getWinWidth()/2) / (getWinWidth() + 30) ) * getWinRatio();
	return m_mouseWinX;
}
float MouseUtility::getGLMouseY()
{
	m_mouseWinY = (float) -(getMouseY() - getWinHeight()/2) / (getWinHeight() + 15);
	return m_mouseWinY;
}
